<div class = "pt-table-wrap" ng-app = "ptcms">
    <h4 class = "pt-msg-title"><b class = "f-fl">广告管理</b></h4>
    <div class = "pt-list" ng-controller = "showlist">
        <form method = "post" action = "__URL__/multi" id="showtable">
            <input type = "hidden" name = "method" />
            <div class = "pt-list-header">
                <div class = "pt-list-operate f-fl">
                    <a class = "btn btn-success btn-sm" href = '__URL__/add'>添加</a>
                    <input type = "submit" class = "btn btn-primary btn-sm btn-checkbox" value = "重建JS" name = "rebuild">
                    <input type = "submit" class = "btn btn-primary btn-sm btn-checkbox" value = "禁用" name = "forbidden">
                    <input type = "submit" class = "btn btn-primary btn-sm btn-checkbox" value = "恢复" name = "recover">
                    <input type = "submit" class = "btn btn-danger btn-sm btn-checkbox" value = "删除" name = "mdel">
                </div>
                <div class = "f-fr">
                    <input ng-model = 'keyword' class = "input-text w160" type = "text" onkeypress = "if(event.keyCode==13) {return false;}" />
                    <input type = "button" class = "btn btn-default btn-sm" value = "搜索" />
                </div>
                <div class = "f-clear"></div>
            </div>
            <table class = "pt-list-table">
                <thead>
                <tr>
                    <th class = "w-checkbox"><input type = "checkbox" class = "checkall" data = "id[]" ></th>
                    <th>广告名称</th>
                    <th class = "w-word2">宽</th>
                    <th class = "w-word2">高</th>
                    <th class = "w-word5">创建人</th>
                    <th class = "w-time">创建时间</th>
                    <th class = "w-word5">修改人</th>
                    <th class = "w-time">修改时间</th>
                    <th class = "w-word3">状态</th>
                    <th class = "operate w-operate4">操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat = "loop in lists | filter:keyword">
                    <td><input type = "checkbox" name = "id[]" value = "{{loop.id}}"></td>
                    <td class = "f-tal" title="{{loop.intro}}">{{loop.name}}({{loop.key}})</td>
                    <td>{{loop.width}}</td>
                    <td>{{loop.height}}</td>
                    <td>{{loop.create_username}}</td>
                    <td>{{loop.create_time}}</td>
                    <td>{{loop.update_username}}</td>
                    <td>{{loop.update_time}}</td>
                    <td>
                        <span class = "label label-warning" ng-if = "loop.status==0" ng-click = "changestatus($index,1)">禁用</span>
                        <span class = "label label-success" ng-if = "loop.status==1" ng-click = "changestatus($index,0)">正常</span>
                    </td>
                    <td class = "operate">
                        <a ng-href = "{{loop.url_show}}"><i class = "icon icon-search"></i>预览</a>
                        <a href = "javascript:;" data-key = "{{loop.key}}" class = "adgetcode"><i class = "icon icon-send"></i>调用</a>
                        <a ng-href = "{{loop.url_edit}}"><i class = "icon icon-edit"></i>编辑</a>
                        <a href = "javascript:;" ng-click = "del(loop.id,$index)"><i class = "icon icon-trash"></i>删除</a>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class = "pt-list-footer">
                <div class = "pt-list-operate f-fl"></div>
                <div class = "f-clear"></div>
            </div>
        </form>
    </div>
</div>
<div class = "pt-pop f-dn" id = "showbox">
    <div class = "pt-set-content">
        <div class = "pt-set-info">
            <div class = "auth"><b>模版语法：</b>
                <input name = "tplcode" type = "text" value = "" class = "input-text" style = "width:300px" />
            </div>
        </div>
        <div class = "pt-set-info">
            <div class = "auth"><b>Js直接调用：</b>
                <input name = "jscode" type = "text" value = "" class = "input-text" style = "width:300px" />
            </div>
        </div>
        <div class = "pt-set-info">
            <div class = "auth">
                <b></b>
                <span class = "btn btn-primary copybtn tplcode">复制模版标签</span>
                <span class = "btn btn-primary copybtn jscode">复制JS语句</span>
            </div>
        </div>
    </div>
</div>
{include file="/application/admin/view/public_indexjs.html"}
<script type = "text/javascript" src = "__PUBLIC__/plugin/zclip/zclip.min.js"></script>
<script type = "text/javascript">
    var tplcode,jscode;
    var copyfn = function () {
        $('.copybtn').zclip({
            'path': '__PUBLIC__/plugin/zclip/zclip.swf',
            'afterCopy': function () {
                alert('复制成功');
            },
            'copy': function () {
                console.log($(this).is('.tplcode'));
                if ($(this).is('.tplcode')){
                    return tplcode;
                }else{
                    return jscode;
                }
            }
        });
    };
    $(function () {
        //显示广告调用代码
        $('.adgetcode').on('click', function () {
            var key=$(this).data('key');
            tplcode = '{$pt.getad.' + key + '}';
            jscode = '<script type="text/javascript" src="{$pt.PT_DIR}/public/{$pt.config.addir}/' +key+'.js"></';
            jscode += 'script>';
            $('input[name=tplcode]').val(tplcode);
            $('input[name=jscode]').val(jscode);
            $.admin.tool.tipbox('#showbox', '复制代码', copyfn);
        });
    })
</script>